package com.atguigu.yygh.hosp.controller.user;

import com.atguigu.yygh.common.result.R;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;
import com.atguigu.yygh.vo.hosp.ScheduleOrderVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/*==========================================
      时 间:   2022-03-15
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
 ==========================================*/
@RestController
@RequestMapping("/user/hosp/hospital")
public class UserScheduleController {

    @Autowired
    private ScheduleService scheduleService;

    @GetMapping("getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getBookingScheduleRule(@PathVariable Integer page,
                                    @PathVariable Integer limit,
                                    @PathVariable String hoscode,
                                    @PathVariable String depcode){
        Map<String,Object> map=scheduleService.getBookingScheduleRule(page,limit,hoscode,depcode);
        return R.ok().data(map);
    }


    @ApiOperation(value = "获取排班数据")
    @GetMapping("findScheduleList/{hoscode}/{depcode}/{workDate}")
    public R findScheduleList( @PathVariable String hoscode,
                               @PathVariable String depcode,
                               @PathVariable String workDate){
        List<Schedule> list= scheduleService.findScheduleList(hoscode,depcode,workDate);
        return R.ok().data("list",list);
    }



    @GetMapping("getSchedule/{id}")
    public R getScheduleInfoById(@PathVariable String id){
        Schedule schedule=scheduleService.getScheduleInfoById(id);
        return R.ok().data("schedule",schedule);
    }

    //不建议：接口复用

    //该接口是给service_order模块远程调用使用的
    @GetMapping("inner/getScheduleOrderVo/{scheduleId}")
    public ScheduleOrderVo getScheduleById(@PathVariable(value = "scheduleId") String scheduleId){
        return scheduleService.getScheduleOrderInfoById(scheduleId);
    }
}
